package tmproject.hlhj.fhp.tmvote

import android.os.Bundle
import android.support.v4.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.example.mymvp.BaseMVP
import com.example.mymvp.BasePresenter
import com.example.mymvp.BaseView
import com.tenma.ventures.base.TMFragment
import tmproject.hlhj.fhp.tmvote.customView.LoadingDialog

/**
 * Created by Never Fear   on 2018\8\23 0023.
Never More....
 */
abstract class BaseFgm<V:BaseView,P:BasePresenter<*,V>>:Fragment(),BaseMVP<V,P> {
    lateinit var rootView:View
    var presenter:P?=null
    lateinit var loadingDialog: LoadingDialog

    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
        log("fhppp","onCreateView")
        rootView=inflater.inflate(getContentId(),null)
        loadingDialog=LoadingDialog(context!!)
        presenter=createPresenter()
        presenter?.let {
            it.createModule()
            it.bindView(bindView())
            it.initView()
            it.setListener()
            it.logicStart()
        }
        log("fhppp","返回Rootview")

        return rootView
    }

    override fun onDestroy() {
        super.onDestroy()
        presenter?.let {
            it.destory()
        }
    }
    abstract fun getContentId():Int
}